package com.qf.ssm.controller.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2 //开启swagger2
@Configuration
public class SwaggerConfig {

    //主要配置的就是我们要处理哪些接口,将哪些接口转换为在线文档,主要就是设置 controller 的包
    @Bean
    public Docket docket(ApiInfo apiInfo){
        return new Docket(DocumentationType.SWAGGER_2)//
                .select().apis(RequestHandlerSelectors.basePackage("com.qf.ssm.controller"))
                .build().apiInfo(apiInfo);
    }

    @Bean
    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()//
                .title("什么是 title")//
                .contact(new Contact("张三","http://www.baidu.com","tcy200302@.163com"))
                .description("这个是description")
                .license("license")
                .licenseUrl("http://www.baidu.com")
                .version("dasd.asd2314.ad4234")
                .build();
    }
}
